package cn.ycc1.boot3redisson.aspect;

import cn.ycc1.boot3redisson.annotation.Redisson;
import lombok.RequiredArgsConstructor;
import org.redisson.api.RedissonClient;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.aop.support.annotation.AnnotationMatchingPointcut;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author ycc
 * @date 2024/07/30 14:22
 */
@Configuration
@RequiredArgsConstructor
public class InterceptorConfig {
    //注意该地址为项目具体包地址
//    public static final String traceExecution = "execution(* cn.ycc1.testpdf.controller.*.*(..))";
//    public static final String traceExecution = "annotation(cn.ycc1.testpdf.annotation.InterceptorAnnotation)";
//    private final RedissonClient redissonClient;
//
//    @Bean
//    public DefaultPointcutAdvisor defaultPointcutAdvisor2() {
//        MyInterceptor interceptor = new MyInterceptor(redissonClient);
////        AspectJExpressionPointcut pointcut = new AspectJExpressionPointcut();
////        pointcut.setExpression("annotation(cn.ycc1.testpdf.annotation.InterceptorAnnotation)");
//
//        // 配置增强类advisor
//        DefaultPointcutAdvisor advisor = new DefaultPointcutAdvisor();
//        advisor.setPointcut(AnnotationMatchingPointcut.forMethodAnnotation(Redisson.class));
//        advisor.setAdvice(interceptor);
//        return advisor;
//    }
}
